//
//  WZUserUtils.swift
//  OfficeExaminationSwift
//
//  Created by Yeeewz on 2018/1/15.
//  Copyright © 2018年 Yeeewz. All rights reserved.
//

import Foundation
//import WZUserInfo

class WZUserUtils {
    let userInfoKey = "userInfo"
    //存储用户信息
    func saveUserInfo(userInfo:WZUserInfo) -> Void {
        let user = UserDefaults.standard
        let userData = NSKeyedArchiver.archivedData(withRootObject: userInfo)
        user.set(userData, forKey: userInfoKey)
        user.synchronize()
    }

    //获取用户信息
    func getUserInfo() -> WZUserInfo {
        
        let userData = UserDefaults.standard.object(forKey: userInfoKey)
        let userInfo = NSKeyedUnarchiver.unarchiveObject(with: userData as! Data)
        
        return userInfo as! WZUserInfo
    }
    //清除用户信息
    func clearUserInfo() -> Void {
        UserDefaults.standard.removeObject(forKey: userInfoKey)
        UserDefaults.standard.synchronize()
    }
}





























